import { ADD_PERSON } from "../constant";

const initPersons = [
  { id: '001', name: 'tom', age: 18 }
]
export default function personReducer(preState = initPersons, action) {
  // 从action对象中获取type，data
  const { type, data } = action
  console.log(type, data);
  switch (type) {
    case ADD_PERSON:
      return [data, ...preState]
    default:
      return preState
  }
}